import { encode, hmac } from "./deps.ts";

export function urlSafeBase64Encode(jsonFlags: string): string {
  const encoded = encode(jsonFlags);
  return base64ToUrlSafe(encoded);
}

export function base64ToUrlSafe(v: string): string {
  return v.replace(/\//g, "_").replace(/\+/g, "-");
}
export function hmacSha1(encodedFlags: string, secretKey: string): string {
  const buf = hmac("sha1", secretKey, encodedFlags);
  return encode(buf);
}
